﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MS.Data.API.Write.Applicant.Command.User;
using MS.Data.ErrorCode;

namespace MS.Data.API.Write.Controllers
{
    /// <summary>
    /// API控制器-写 用户
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManUserController : ControllerBase
    {
        IMediator mediator;

        public ManUserController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="add"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddUser(AddUserCommand add)
        {
            return await mediator.Send(add);
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DelUser([FromQuery]DelUserCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Domain.User>>> UpdUser([FromQuery]UpdUserCommand request)
        {
            return mediator.Send(request);
        }

        [HttpPut]
        public Task<APIResult<int>> XiuUser(XiuUserCommand request)
        {
            return mediator.Send(request);
        }
    }
}
